package com.itheima.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.YYFBodyManagerDao;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.pojo.YYFBody;
import org.springframework.beans.factory.annotation.Autowired;

@Service(interfaceClass = YYFBodyManagerService.class)
public class YYFBodyManagerServiceImpl implements YYFBodyManagerService{
    @Autowired
    private YYFBodyManagerDao bodyManagerDao;
    //分页显示所有的body
    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {
        Integer currentPage = queryPageBean.getCurrentPage();
        Integer pageSize = queryPageBean.getPageSize();
        PageHelper.startPage(currentPage,pageSize);
        //通过子查询查出所有的用户的所有角色的所有菜单项
        Page<YYFBody> page = bodyManagerDao.findAllBody();
        return new PageResult(page.getTotal(),page.getResult());
    }
    //根据ID删除BODY项
    @Override
    public void deleteById(Integer id) {
        bodyManagerDao.deleteById(id);
    }
    //根据ID查询body项用于编辑时回显数据
    @Override
    public YYFBody findById(Integer id) {
        return bodyManagerDao.findById(id);
    }
    //编辑body项
    @Override
    public void edit(YYFBody body) {
        bodyManagerDao.edit(body);
    }
}
